import request from '@/utils/request'
import {POS_SERVER_URL} from '@/utils/common'
import {getSignedParams} from '@/utils/sign'

/**
 * 创建主卡
 * @returns
 */
export function makeCardMaster (item) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/makeMaster',
    method: 'post',
    data: getSignedParams(item)
  })
}

/**
 * 获取卡基础信息
 * @param {*} cardNo
 * @returns
 */
export function getCardInfo (cardNo) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/info',
    method: 'post',
    data: getSignedParams({cardNo: cardNo})
  })
}

/**
 * 获取卡基础信息
 * @param {*} cardUid
 * @returns
 */
export function getCardInfoByUid (cardUid) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/infoByUid',
    method: 'post',
    data: getSignedParams({uid: cardUid})
  })
}

/**
 * 创建副卡
 * @param {*} item
 * @returns
 */
export function makeCardSecond (item) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/makeSecond',
    method: 'post',
    data: getSignedParams(item)
  })
}

/**
 * 充值退款
 * @param {*} rechargeId
 * @returns
 */
export function rechargeRefund (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/recharge/refund',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 获取储值卡消费记录
 * @param {*} params
 * @returns
 */
export function getCardConsumptionList (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/consumption/list',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 会员绑定
 * @param {*} params
 * @returns
 */
export function bindMember (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/bindMember',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 解绑会员
 * @param {*} params
 * @returns
 */
export function unbindMember (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/unbindMember',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 根据电话号码获取主卡信息
 * @param {*} params
 * @returns
 */
export function masterCardListByPhone (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/masterCardListByPhone',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 主卡挂失
 * @param {*} params
 */
export function masterReportLost (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/masterReportLost',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 主卡解除挂失
 * @param {*} params
 * @returns
 */
export function masterUndoReportLost (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/masterUndoReportLost',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 更新主卡密码
 * @param {*} item
 * @returns
 */
export function updateCardPassword (item) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/updateCardPassword',
    method: 'post',
    data: getSignedParams(item)
  })
}

/**
 * 主卡基础信息更改
 * @param params
 * @returns
 */
export function masterUpdateCardInfo (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/masterUpdateCardInfo',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 副卡基础信息更改
 * @param params
 * @returns {*}
 */
export function secondUpdateCardInfo (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/secondUpdateCardInfo',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 更新主卡开票类型
 * @param {*} item
 * @returns
 */
export function updateInvoiceType (item) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/updateInvoiceType',
    method: 'post',
    data: getSignedParams(item)
  })
}

/**
 * 更新副卡密码
 * @param {*} item
 * @returns
 */
export function updateCardSecondPassword (item) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/updateSecondCardPassword',
    method: 'post',
    data: getSignedParams(item)
  })
}

/**
 * 换卡
 * @param params
 */
export function changeCardNo (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/changeCardNo',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 根据电话号码获取副卡信息
 * @param params
 * @returns {*}
 */
export function secondCardListByPhone (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/secondCardListByPhone',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 获取写卡记录
 * @param cardNo
 * @returns {*}
 */
export function getWriteCardRecords (cardNo) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/getWriteCardRecords',
    method: 'post',
    data: getSignedParams({cardNo: cardNo})
  })
}

/**
 * 添加写卡记录
 * @param params
 * @returns {*}
 */
export function addWriteCardRecord (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/addWriteCardRecord',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 获取公司列表
 * @param stationId
 * @returns {*}
 */
export function getCardCompanyList (stationId) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/getCardCompanyList',
    method: 'post',
    data: getSignedParams({stationId: stationId})
  })
}

/**
 * 获取卡充值记录
 * @param params
 * @returns {*}
 */
export function getCardRechargeList (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/getCardRechargeList',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 副卡挂失
 * @param {*} params
 */
export function secondReportLost (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/secondReportLost',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 副卡解除挂失
 * @param {*} params
 * @returns
 */
export function secondUndoReportLost (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/secondUndoReportLost',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 获取储值卡消费记录
 * @param fuelRecordId
 * @returns {*}
 */
export function getCardConsumptionRecord (fuelRecordId) {
  return request({
    url: POS_SERVER_URL + '/api/pc/card/getCardConsumptionRecord',
    method: 'post',
    data: getSignedParams({fuelRecordId: fuelRecordId})
  })
}
